package alvarodelrosal.chat.server.modelo.chataction;

import alvarodelrosal.chat.server.infraestructura.ChatLiveConversations;
import alvarodelrosal.chat.server.modelo.ChatConnection;
import alvarodelrosal.chat.server.modelo.ChatMessage;
import alvarodelrosal.chat.server.modelo.ChatUser;
import java.util.List;

public class ChatChat implements ChatAction {

    @Override
    public String getName() {
        return "Chat";
    }

    @Override
    public boolean needsAdminPrivileges() {
        return false;
    }

    @Override
    public boolean needsLogin() {
        return true;
    }

    @Override
    public String doAction(ChatConnection connection, List<String> parameters) {
        ChatUser user = connection.whoAmI();
        ChatMessage message = new ChatMessage(user, parameters.get(1));
        ChatLiveConversations.addMessage(message, Integer.parseInt(parameters.get(0)));
        return "";
    }
    
}
